Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make from_file and other laser init compatible #1157

Merged
merged 22 commits into from
Oct 10, 2024

Conversation

huixingjian
Copy link
Contributor

@huixingjian huixingjian commented Sep 6, 2024

PR Description

This code enhances laser generation by supporting multiple methods of laser initialization, including gaussian, parser, and from_file. Lasers are instantiated via the Laser class and sequentially added to the Multilaser instancem_multilaser.

However, previously, the methods for reading lasers from an openPMD file—specifically, void GetEnvelopeFromFileHelper() and void GetEnvelopeFromFile()—were directly defined in the Multilaser class. As a result, when these methods were activated, no additional Laser instances could be added to m_multilaser, leading to an incompatibility between from_file and the other methods (gaussian and parser).

Issue addressed

This pull request resolves the conflict by refactoring the code. It moves the member variables and functions related to reading laser data from a file, including:

void GetEnvelopeFromFileHelper ()
void GetEnvelopeFromFile ()
bool m_laser_from_file = false;
/** full 3D laser data stored on the host */
amrex::FArrayBox m_F_input_file;
/** path to input openPMD file */
std::string m_input_file_path;
/** name of the openPMD species in the file */
std::string m_file_envelope_name = "laserEnvelope";
/** index of the iteration in the openPMD file */
int m_file_num_iteration = 0;
/** Geometry of the laser file, 'rt' or 'xyt' */
std::string m_file_geometry = "";
/** Wavelength from file */
amrex::Real m_lambda0_from_file {0.};

from Multilaser class to Laser class. With this change, the laser data can be loaded via the Laser class and then added to m_multilaser, just like with the other initialization methods.

Benefits

Together with PR #1122 and PR #866, this update allows the code to initialize multiple lasers using any combination of parser, gaussian, and from_file methods.The default initialization option for <laser_name>.init_type is now gaussian, with additional options being parser and from_file.

Important Note

Currently, all lasers must share the same central wavelength. If the lasers.lambda0 of a laser does not match the wavelength loaded from the file, the code will raise an error.

Test

This PR is tested through the input script:
From_file_input.txt

And three lasers respectively from different methods are generated.
Screenshot 2024-08-05 at 19 27 08

@huixingjian huixingjian changed the title [WIP]Read from file commitfix Make from_file and other laser init compatible Sep 6, 2024
Copy link
Member

@MaxThevenet MaxThevenet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this PR! See comments below.

@@ -912,17 +912,17 @@ Option: ``gaussian``

Option: ``from_file``

* ``lasers.input_file`` (`string`) optional (default `""`)
* ``<laser name>.input_file`` (`string`) (default `""`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's still optional, isn't it?

src/laser/Laser.cpp Outdated Show resolved Hide resolved
src/laser/Laser.cpp Outdated Show resolved Hide resolved
src/laser/Laser.H Outdated Show resolved Hide resolved

class Laser
{
public:

Laser (std::string name);
/** \brief Read in a laser from an openPMD file */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you document the argument laser_geom_3D? You'll find plenty of examples in the rest of the code how to do that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the comment. The argument is documented in the file

src/laser/Laser.cpp Show resolved Hide resolved
src/laser/MultiLaser.cpp Outdated Show resolved Hide resolved
src/laser/MultiLaser.cpp Outdated Show resolved Hide resolved
@huixingjian huixingjian changed the title Make from_file and other laser init compatible [WIP]Make from_file and other laser init compatible Oct 7, 2024
Co-authored-by: Alexander Sinn <[email protected]>
@huixingjian huixingjian changed the title [WIP]Make from_file and other laser init compatible Make from_file and other laser init compatible Oct 8, 2024
Copy link
Member

@MaxThevenet MaxThevenet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks for this PR!

@@ -871,70 +871,60 @@ Parameters starting with ``lasers.`` apply to all laser pulses, parameters start
Whether to use the most stable discretization for the envelope solver.

* ``<laser name>.init_type`` (list of `string`) optional (default `gaussian`)
The initializing method of laser. Possible options are:
The initialisation method of laser. Possible options are:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consistency. We use US English.

Suggested change
The initialisation method of laser. Possible options are:
The initialization method of laser. Possible options are:


* ``gaussian``(default) the laser is iniliatized with an ideal gaussian pulse.
Option: ``gaussian`` (default) the laser is initialised with an ideal gaussian pulse.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Option: ``gaussian`` (default) the laser is initialised with an ideal gaussian pulse.
Option: ``gaussian`` (default) the laser is initialized with an ideal gaussian pulse.

@MaxThevenet MaxThevenet merged commit 6b00da3 into Hi-PACE:development Oct 10, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants